package lab05.servlets;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class CalcularOperacionServlet
 */
@WebServlet("/CalcularOperacionServlet")
public class CalcularOperacionServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public CalcularOperacionServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String operadora = request.getParameter("operadora");
		String operadorb = request.getParameter("operadorb");
		String operacion = request.getParameter("select01");
		
		System.out.println("Operador A "+operadora);
		System.out.println("Operador B "+operadorb);
		System.out.println("Operacion "+operacion);
	
		// Guardar en memoria
        request.setAttribute("RESULTADO", operacion);
        
		RequestDispatcher rd = 
			        request.getRequestDispatcher("ejercicio1.jsp");
			        rd.forward(request, response);
	}

}
